<template>
  <el-form ref="formBzz" :model="formBzzUserTeam" :rules="rulesBzz" label-width="150px" class="showDisabledClas">
    <el-row>
      <el-col :span="12">
        <el-form-item label="直推参与投资的人数">
          <el-input v-model="formBzzUserTeam.recommendInvestCount"  disabled/>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="团队有投资的人数">
          <el-input v-model="formBzzUserTeam.teamInvestUserCount"  disabled />
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="团队总投资数量">
          <el-input v-model="formBzzUserTeam.teamInvestAmount"  disabled/>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="是否投资">
          <el-radio-group v-model="formBzzUserTeam.investFlag" disabled size="small">
            <el-radio-button label="1">是</el-radio-button>
            <el-radio-button label="0">否</el-radio-button>
          </el-radio-group>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>

      <el-col :span="12">
        <el-form-item label="用户等级" prop="level">
          <el-input-number v-model="formBzzUserTeam.level"  controls-position="right" :min="0" :max="6"/>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="等级固定">
          <el-radio-group v-model="formBzzUserTeam.fixLevelFlag" size="small">
            <el-radio-button label="1">是</el-radio-button>
            <el-radio-button label="0">否</el-radio-button>
          </el-radio-group>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="个人算力值" prop="power">
          <el-input v-model="formBzzUserTeam.power"/>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="购买的存储容量">
          <el-input v-model="formBzzUserTeam.buyPower" disabled/>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="已封装的存储容量">
          <el-input v-model="formBzzUserTeam.packagePower" disabled/>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="团队算力">
          <el-input v-model="formBzzUserTeam.teamPower" disabled/>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row >
      <el-col :span="12">
        <el-form-item label="大区算力">
          <el-input v-model="formBzzUserTeam.bigDistrictPower" disabled/>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="小区算力之和">
          <el-input v-model="formBzzUserTeam.totalTinyDistrictPower" disabled/>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="投入矿池的总金额">
          <el-input v-model="formBzzUserTeam.investAmount"  disabled/>
        </el-form-item>
      </el-col>
    </el-row>
    <el-form-item class="fr">
      <el-button type="primary" size="mini" @click="submitBzz">保存</el-button>
      <el-button  size="mini" @click="close">取消</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
import {isNumber} from "@/utils/validate";
import {updateUserTeam} from "@/api/biz";

export default {
  props: {
    formBzzUserTeam: {
      type: Object
    }
  },
  data() {
    const validPower = (rule, value, callback) => {
      if (!isNumber(value)) {
        callback(new Error("请输入数字"));
      } else {
        callback();
      }
    };
    return {
      // 表单校验
      rulesBzz: {
        power: [
          { required: true, message: "算力值不能为空", trigger: "blur" },
          { required: true, validator: validPower, trigger: "blur" }
        ]
      }
    };
  },
  methods: {
    submitBzz(){
      this.$refs["formBzz"].validate(valid => {
        if (valid) {
          updateUserTeam(this.formBzzUserTeam).then(res => {
            this.msgSuccess("修改成功");
            this.$emit("onTell", res);
          });
        }
      });
    },
    close() {
      this.$emit("onTell", {code: 200});
    }
  }
};
</script>
<style lang="scss">
.showDisabledClas {
  .el-input.is-disabled .el-input__inner,  .el-textarea.is-disabled .el-textarea__inner{
    color: #606266;
  }
}
</style>
